﻿#pragma once

#include "Core/Window.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "Core/Renderer/GraphicsContext.h"

namespace Origin
{
    class WindowsWindow: public Window
    {
    public:
        WindowsWindow(const WindowProps& props);
        virtual ~WindowsWindow();

        void OnUpdate() override;
        void SetSync(bool enabled) override;
        void Shutdown() override;

        unsigned int GetWidth() override { return _pointerData.width; }
        unsigned int GetHeight() override { return _pointerData.height; }

        // EventCallbackFn是一个参数为Event&，返回值为void的方法
        inline void SetEventCallback(const EventCallbackFn callback) override
        {
            _pointerData.callback = callback;
        }

        inline void* GetNativeWindow() const override { return _glfwWindow; };

    private:
        void Init(const WindowProps& props);
        GLFWwindow* _glfwWindow;
        GraphicsContext* _graphicsContext;

        struct PointerData
        {
            std::string title;
            unsigned int width, height;
            EventCallbackFn callback;
        };

        PointerData _pointerData;
    };


}

